#include<bits/stdc++.h>
using namespace std;
int t,n,m,l,V,d[100005],v[100005],a[100005],p[100005],ans,need;
double f,e;
bool www[1000005];
struct ff{
    int l,r=1e9;
    bool operator < (const ff & A) const{
        return r<A.r;
    }
}b[100005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--){
        memset(www,false,sizeof(www));
        need=ans=0;
        scanf("%d%d%d%d",&n,&m,&l,&V);
        for(int i=1;i<=n;i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++){
            scanf("%d",&p[i]);
            www[p[i]]=true;
        }
        sort(p+1,p+m+1);
        for(int i=1;i<=n;i++){
            f=e=-1;
            if(a[i]==0){
                if(v[i]>V){
                    f=d[i];
                    e=l;
                }
            }else if(a[i]>0){
                if(v[i]>V){
                    f=d[i];
                    e=l;
                }else{
                    if(ceil(sqrt(v[i]*v[i]+2*a[i]*(l-d[i])))>V){
                        e=l;
                        if((V*V-v[i]*v[i])%(a[i]*2)==0) f=min((double)l,(double)((V*V-v[i]*v[i])/(a[i]*2)+d[i]+1));
                        else f=min((double)l,ceil((V*V-v[i]*v[i])/(a[i]*2)+d[i]));
                    }
                }
            }else{
                if(v[i]>V){
                    f=d[i];
                    if((V*V-v[i]*v[i])%(a[i]*2)==0) e=min((double)l,(double)((V*V-v[i]*v[i])/(a[i]*2)+d[i]-1));
                    else e=min((double)l,floor((V*V-v[i]*v[i])/(a[i]*2)+d[i]));
                }
            }
            if(f==-1&&e==-1) continue;
            for(int i=f;i<=e;i++){
                if(www[i]){
                    ans++;
                    b[ans].l=f;
                    b[ans].r=e;
                    break;
                }
            }
        }
        printf("%d ",ans);
        sort(b+1,b+ans+1);
        int w=1,ww=1;
        while(true){
            if(w>ans) break;
            need++;
            while(p[ww]<=b[w].r&&ww<=m) ww++;
            ww--;
            while(b[w].l<=p[ww]&&w<=ans) w++;
        }
        printf("%d\n",m-need);
    }
    return 0;
}
